window.lhp_run_func=function(str_,obj=null,test=false){
    if ((typeof str_) ==='function'){
        if (obj!=null){
            return str_(obj)
        }else{
            return str_()
        }
    }
    try{
        if (str_==''){return null;}
        else if (str_.includes('.')){
            let arr = str_.split('.');  
            let run_func=window
            for (let i=0;i<arr.length-1;i++){ run_func=run_func[arr[i]]}
            if (obj!=null){
                if(test){console.log("lhp_run_func func params:",run_func[arr[arr.length-1]],obj)
}
                return run_func[arr[arr.length-1]](obj)
            }else{
                return run_func[arr[arr.length-1]]()
            }
        }else{
            if (obj!=null){
                return window[str_](obj)
            }else{
                return window[str_]()
            }
        }
        
  }catch(err){if(test){console.log("lhp_run_func err:",err);
}}
}

async function lhp_run_func2_run_func(fn,obj=null) {
    if (fn.constructor.name === 'AsyncFunction') {
        // 如果是 async 函数，使用 await
        if(obj!=null){
            return await fn(obj);

        }else{
            return await fn();
        }
    } else {
        // 如果是普通函数，直接调用
        if(obj!=null){
            return fn(obj);

        }else{
            return fn();
        }
    }
}
window.lhp_run_func2=async function(str_,obj=null,test=false){
    if ((typeof str_) ==='function'){
        await lhp_run_func2_run_func(str_,obj);
    }
    try{
        if (str_==''){return null;}
        else if (str_.includes('.')){
            let arr = str_.split('.');  
            let run_func=window
            for (let i=0;i<arr.length-1;i++){ run_func=run_func[arr[i]]}
            await lhp_run_func2_run_func(run_func[arr[arr.length-1]],obj);
        }else{
            await lhp_run_func2_run_func(window[str_],obj);
        }
        
  }catch(err){if(test){console.log("lhp_run_func err:",err);
}}
}